package application.common.util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.net.URL;
import java.net.URLDecoder;

public class FiltUtil {
	public static String getPath() {
		URL url = FiltUtil.class.getProtectionDomain().getCodeSource().getLocation();
		String filePath = null;
		try {
			filePath = URLDecoder.decode(url.getPath(), "utf-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
		filePath = filePath.substring(1, filePath.lastIndexOf("/") + 1);
		return filePath;
	}
	
	
	 public static boolean writeFile(String path, String content) {
		  Writer writer = null;
	        try {
	   		 
		        File file = new File(path);
		        if(!file.exists()) {
		        	file.createNewFile();
		        }
	            writer = new FileWriter(file, false); 
	            writer.write(content);
	            return true;
	        } catch (IOException e) {
	        } finally {
	            try {
	                writer.close();
	            } catch (IOException e2) {
	            }
	        }
	        return false;
	    }
	
}
